local zhulei = fk.CreateSkill{
  name = "hanqing__zhulei",
}

Fk:loadTranslationTable{
  ["hanqing__zhulei"] = "筑垒",
  [":hanqing__zhulei"] = "当你使用伤害牌指定目标后，或当你成为伤害牌的目标后，你可以弃置两张牌，若这两张牌：颜色相同，你摸一张牌；"..
  "类别相同，你可以移动场上一张牌；若均满足，此牌造成的伤害-1。",

  ["#hanqing__zhulei-invoke"] = "筑垒：是否弃两张牌？颜色相同摸一张牌，类别相同可以移动场上一张牌，均满足则伤害-1",
  ["#hanqing__zhulei-move"] = "筑垒：你可以移动场上一张牌",
}

local spec = {
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askToDiscard(player, {
      min_num = 2,
      max_num = 2,
      include_equip = true,
      skill_name = zhulei.name,
      prompt = "#hanqing__zhulei-invoke",
      cancelable = true,
      skip = true,
    })
    if #cards == 2 then
      event:setCostData(self, {cards = cards})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = table.simpleClone(event:getCostData(self).cards)
    local color1, color2 = Fk:getCardById(cards[1]).color, Fk:getCardById(cards[2]).color
    local type1, type2 = Fk:getCardById(cards[1]).type, Fk:getCardById(cards[2]).type
    room:throwCard(cards, zhulei.name, player, player)
    if player.dead then return end
    if color1 == color2 and type1 == type2 then
      data.additionalDamage = (data.additionalDamage or 0) - 1
    end
    if color1 == color2 then
      player:drawCards(1, zhulei.name)
    end
    if player.dead then return end
    if type1 == type2 and #room:canMoveCardInBoard() > 0 then
      local targets = room:askToChooseToMoveCardInBoard(player, {
        prompt = "#hanqing__zhulei-move",
        skill_name = zhulei.name,
        cancelable = true,
      })
      if #targets == 2 then
        room:askToMoveCardInBoard(player, {
          target_one = targets[1],
          target_two = targets[2],
          skill_name = zhulei.name,
        })
      end
    end
  end,
}

zhulei:addEffect(fk.TargetSpecified, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhulei.name) and data.firstTarget and
      data.card.is_damage_card and #player:getCardIds("he") > 1
  end,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

zhulei:addEffect(fk.TargetConfirmed, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhulei.name) and
      data.card.is_damage_card and #player:getCardIds("he") > 1
  end,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

return zhulei
